<?php

namespace App\Enums\OpenShop\InvestmentPromotion;

use App\Http\Middleware\OpenShop\FeishuWebAuth;
use App\Models\OpenShop\Common\MallSettleInShopInfoModel;
use App\Models\OpenShop\Common\SiteLocationMallModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopUploadFileResourceModel;
use App\Models\OpenShop\SiteLocation\OpenShopSiteLocationModel;
use App\Models\OpenShop\SiteLocation\OpenShopSiteLocationProductAnalysisModel;
use App\Service\Common\CommonService;
use App\Service\Common\HeatMapService;
use App\Service\OpenShop\SiteLocation\SiteLocationService;
use App\Service\WaiMai\WaiMaiAnalysisService;
use Closure;
use GuzzleHttp\Client;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Kuafu\File\FileUtil;

class SiteLocationFormEnum
{

    public Collection   $orgData; // 原数据
    public static array $customerField         = []; // 数据字段自定义
    public static array $siteLocationFormGroup = [];
    public static array $shopAttributeData     = []; // rms门店属性配置


    public int $source = OpenShopSiteLocationModel::SOURCE_OPEN_SHOP;

    /**
     * @param Collection $orgData 原数据
     * @param int $source 来源
     */
    public function __construct(
        Collection $orgData,
        int $source = OpenShopSiteLocationModel::SOURCE_OPEN_SHOP
    ) {
        $this->orgData = $orgData;
        $this->source  = $source;
    }


    public static function setCustomerField(array $fieldArr = [])
    {
        self::$customerField = $fieldArr;
    }

    /**
     * 获取最小可用字段
     *
     * @param string $field
     * @param string $text
     * @param bool|Closure $required
     * @param string $input
     * @param array $options
     * @param array|Closure $extField
     * @return array
     */
    public static function unit(
        string $field,
        string $text,
        $required,
        string $input,
        array $options = [],
        $extField = []
    ): array {

        switch ($input) {
            case 'radio':
                $iconImg = 'arrow-right';
                break;
            case 'map':
                $iconImg = 'map';
                break;
            default:
                $iconImg = '';
        }

        $data = [
            'field'      => $field,
            'text'       => $text,
            'required'   => $required instanceof Closure ? $required() : $required,
            'input'      => $input,
            'options'    => $options,
            'icon'       => $iconImg,
            'display'    => 'block',
            'isResource' => false
        ];

        if ($extField instanceof Closure) {
            $extField = $extField();
        }

        foreach ($extField as $key => $field) {
            $data[$key] = $field;
        }

        foreach (self::$customerField as $fieldKey => $customerField) {
            if ($data['field'] == $fieldKey) {
                foreach ($customerField as $k => $value) {
                    $data[$k] = $value;
                }
            }
        }

        return $data;
    }

    /**
     *
     * input：radio （单选）需要传选项options
     * input：cascade（级联单选）需要传选项options
     * input：text （文本输入框）
     * input：number（数字输入框）
     * input：textarea（多行文本输入框）
     * input：map（地图）
     * input：address（地址级联选择器）
     * input：albumRadio（相册单选）
     * input：albumCheckbox（相册多选）
     * input：cameraRadio（相册单选）
     * input：cameraCheckbox（相册单选）
     *
     * required：true/false （是否必填）
     *
     * unit：单位
     *
     * icon：arrow-right/map （目前就两种，有箭头和地址图标）
     *
     */

    public function getSiteLocationField(
        $field,
        $value = '',
        int $businessId = 0,
        $oldValue = null
    ) {
        if (!self::$shopAttributeData && in_array($field, ['shopType', 'siteSelection', 'sellingCategory', 'menuLevel', 'posLine'])) {
            $action          = request()->route()->getAction();
            $middleware      = attributeGet($action, 'middleware', []);
            $selectTypeField = 'shopType';
            if (in_array(FeishuWebAuth::class, $middleware)) {// rms后台订单详情查看全部
                $selectTypeField = '';
            }
            self::$shopAttributeData = CommonService::getShopAttributeData($selectTypeField);// rms门店属性配置
        }
        if (empty(self::$siteLocationFormGroup)) {
            self::$siteLocationFormGroup = array_merge(
                self::locationsPhoto(),//门店照片
                self::generatrixInfo(),//动线说明
                self::itemInfo(),//项目信息
                self::operatingState(),//经营状态
                self::engineeringCondition(),//工程条件
                self::businessConditions(),//商务条件
                self::getCapitalBudgeting(),//投资预算
                self::projectSummary(),//项目总结
            );
        }
        $data = array_merge(
            self::$siteLocationFormGroup,
            //todo
            $this->customerAnalyse(),//客群分析,
            $this->takeOutEstimate(),//外卖预估,
            $this->productAnalyse(),//竞品分析/互补品分析
            $this->leaseContractInfo(),//租赁合同信息
        );
        if (null !== $oldValue) {
            $data[$field]['oldValue'] = $oldValue;
        }

        $data[$field]['value'] = '';
        if (is_array($value) || !empty($value)) {
            if (!is_array($value)) {
                $value = (string)$value;
            }

            $data[$field]['value'] = $value;
        } else {
            if ($this->orgData->has($data[$field]["field"])) {

                $fieldVal = (string)$this->orgData->get($data[$field]["field"]);
                switch ($data[$field]["input"]) {
                    case "datetime":
                        $fieldVal = $fieldVal > 0 ? $fieldVal : "";
                        break;
                }
                $data[$field]["value"] = $fieldVal;
            } else {
                if ($data[$field]["isResource"]) {
                    $attachFile = SiteLocationService::$siteLocationModel->attachRel->where("position",
                        $data[$field]["position"])->where('businessId', $businessId);


                    $data[$field]["value"] = $attachFile->isNotEmpty() ?
                        $attachFile->pluck("url")
                                   ->map($attachFile->getIterator()
                                                    ->current()->isPublic ? "picturePath" : "privateFilePath")
                                   ->toArray() : [];
                }
            }
        }
//        if (
//            !empty($this->orgData) &&
//            (!empty($this->orgData[$data[$field]['field']]) || in_array($data[$field]['field'],
//                    SiteLocationEnum::COULD_ZERO_FIELDS))
//        ) {
//            $data[$field] += [
//                'value' => (string)$this->orgData[$data[$field]['field']]
//            ];
//        }
//
//        if (is_array($value) || !empty($value)) {
//            if (!is_array($value)) {
//                $value = (string)$value;
//            }
//            $data[$field]['value'] = $value;
//        }
//
//
//        if (!isset($data[$field]['value'])) {
//            $data[$field]['value'] = '';
//        }

        //if (SiteLocationService::$siteLocationModel->)
        if ($field == 'wmHeatMap') {
            $data[$field]["value"] = $value;
        }

        return $data[$field];
    }


    /**
     * 项目总结
     *
     * @return array
     */
    public static function projectSummary(): array
    {
        /*if (SiteLocationService::$siteLocationModel->shopPattern == OpenShopSiteLocationModel::SHOP_PATTERN_THREE) {
            $patternType = OpenShopSiteLocationModel::PATTERN_TYPE_MAPPING_BY_PATTERN_THREE;
        } else {
            $patternType = OpenShopSiteLocationModel::PATTERN_TYPE_MAPPING_BY_PATTERN_TWO;
        }*/

        return [
            'businessStrategy' => self::unit('businessStrategy', '经营策略', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::BUSINESS_STRATEGY_TEXT)),
//            'restrictedSales'  => self::unit('restrictedSales', '限制销售范围', true, 'checkbox',
//                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RESTRICTED_SALES_TEXT),
//                ['icon' => 'arrow-right', 'max' => 99]),
            'sellingCategory' => self::unit(
                'sellingCategory', '售卖品类', true, 'checkbox',
                SiteLocationEnum::getOptionsByConst(self::getShopAttributeField('sellingCategory')), ['max' => 99]
            ),
            'menuLevel'       => self::unit(
                'menuLevel', '产品定价', true, 'radio',
                SiteLocationEnum::getOptionsByConst(self::getShopAttributeField('menuLevel'))
            ),
            'posLine'         => self::unit(
                'posLine', '点餐动线', true, 'radio',
                SiteLocationEnum::getOptionsByConst(self::getShopAttributeField('posLine'))
            ),
            'openTime'         => self::unit('openTime', '预计开业时间', true, 'datetime', [],
                ['icon' => 'arrow-right']),
//            'shopPattern'      => self::unit('shopPattern', '门店模型', true, 'radio',
//                SiteLocationEnum::getOptionsByConst(OpenShopSiteLocationModel::TEMP_SHOP_PATTERN_MAPPING)),
//            'patternType'      => self::unit('patternType', '售卖品类', true, 'checkbox',
//                SiteLocationEnum::getOptionsByConst($patternType), ['max' => 10]),
            'siteAdvantage'    => self::unit('siteAdvantage', '店址优势', true, 'textarea'),
            'siteInferiority'  => self::unit('siteInferiority', '店址劣势', true, 'textarea'),
        ];
    }

    /**
     * 经营状态
     *
     * @return array
     */
    public static function operatingState(): array
    {
        return [
            // 经营状态
            'currentFormat'   => self::unit('currentFormat', '当前业态', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CURRENT_FORMAT_TYPE_TEXT)),
            'operatingStatus' => self::unit('operatingStatus', '当前经营状态', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::OPERATING_STATUS_TYPE_TEXT)),
            'leaseStatus'     => self::unit('leaseStatus', '租赁状态', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::LEASE_STATUS_TEXT)),
            'driveType'       => self::unit('driveType', '客流驱动', true, 'checkbox',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::DRIVE_TYPE_TEXT),
                ['icon' => 'arrow-right', 'max' => 99]),
            'siteType'        => self::unit('siteType', '店址类型', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::SITE_TYPE_TEXT)),
        ];
    }

    /**
     * 竞品/互补品分析
     *
     * @return array
     */
    public function productAnalyse(): array
    {
        return [
            // 竞品分析 - 1 , 互补品 - 2
            'productName1'           => self::unit('productName', '竞品名称', function () {
                if (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF) {
                    return false;
                } else {
                    return true;
                }
            }, 'text'),
            'productName2'           => self::unit('productName', '互补品名称', function () {
                if (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF) {
                    return false;
                } else {
                    return true;
                }
            }, 'text'),
            'hallFoodNumber1'        => self::unit('hallFoodNumber', '堂食客单量', false, 'number', [],
                ['unit' => '单/月']),
            'hallFoodNumber2'        => self::unit('hallFoodNumber', '堂食客单量', false, 'number', [],
                ['unit' => '单/月']),
            'hallFoodUnitPrice1'     => self::unit('hallFoodUnitPrice', '堂食客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'hallFoodUnitPrice2'     => self::unit('hallFoodUnitPrice', '堂食客单价格', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'elemNumber1'            => self::unit('elemNumber', '饿了么客单量', false, 'number', [],
                ['unit' => '单/月']),
            'elemNumber2'            => self::unit('elemNumber', '饿了么客单量', false, 'number', [],
                ['unit' => '单/月']),
            'elemUnitPrice1'         => self::unit('elemUnitPrice', '饿了么客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'elemUnitPrice2'         => self::unit('elemUnitPrice', '饿了么客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'meituanNumber1'         => self::unit('meituanNumber', '美团客单量', false, 'number', [],
                ['unit' => '单/月']),
            'meituanNumber2'         => self::unit('meituanNumber', '美团客单量', false, 'number', [],
                ['unit' => '单/月']),
            'meituanUnitPrice1'      => self::unit('meituanUnitPrice', '美团客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'meituanUnitPrice2'      => self::unit('meituanUnitPrice', '美团客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'electricityConsumption' => self::unit('electricityConsumption', '用电量', true, 'number', [],
                ['unit' => 'kw']),

            'shopInnerPhoto'              => self::unit('shopInnerPhoto', '门店图片', function () {
                if (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF) {
                    return false;
                } else {
                    return true;
                }
            }, 'albumCheckbox', [], [
                "isResource" => true,
                "position"   => UploadFileResourceEnum::PRODUCT_SHOP_INNER_PHOTO
            ]),
            'dazhongPhoto'                => self::unit('dazhongPhoto', '大众点评截图', false, 'albumCheckbox', [],
                function () {
                    return [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::PRODUCT_SHOP_DAZHONG_PHOTO
                    ];
                }),
            'elemPhoto'                   => self::unit('elemPhoto', '饿了么平台截图', false, 'albumCheckbox', [],
                function () {
                    return [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::PRODUCT_SHOP_ELEM_PHOTO
                    ];
                }),
            'meituanPhoto'                => self::unit('meituanPhoto', '美团平台截图', false, 'albumCheckbox', [],
                function () {
                    return [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::PRODUCT_SHOP_MEITUAN_PHOTO
                    ];
                }),
            'eatInGraduationReceiptPhoto' => self::unit('eatInGraduationReceiptPhoto', '堂食结业小票照片', function () {
                if (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF) {
                    return false;
                } else {
                    return true;
                }
            },
                'albumCheckbox', [], function () {
                    $tempRequired = !$this->orgData->get("existsEatInGraduationReceiptPhoto");
                    if ($tempRequired && (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF)) {
                        $tempRequired = false;
                    }
                    return [
                        "required"   => $tempRequired,
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::PRODUCT_EAT_IN_GRADUATION_RECEIPT_PHOTO
                    ];
                }),
            'specialExplanation'          => self::unit('specialExplanation', '外卖等特殊情况说明', false, 'text', [],
                function () {
                    $attachMtFile  = SiteLocationService::$siteLocationModel->attachRel
                        ->where("position", UploadFileResourceEnum::PRODUCT_SHOP_MEITUAN_PHOTO)
                        ->where('businessId', $this->orgData->get("id", 0));
                    $attachEleFile = SiteLocationService::$siteLocationModel->attachRel
                        ->where("position", UploadFileResourceEnum::PRODUCT_SHOP_ELEM_PHOTO)
                        ->where('businessId', $this->orgData->get("id", 0));
                    $tempRequired = $attachMtFile->isEmpty() && $attachEleFile->isEmpty();
                    if ($tempRequired && (SiteLocationService::$siteLocationModel->shopModelType == SiteLocationEnum::SHOP_MODEL_TYPE_MALL && SiteLocationService::$siteLocationModel->openingStatus == SiteLocationEnum::OPENING_STATUS_OFF)) {
                        $tempRequired = false;
                    }
                    return ["required" => $tempRequired];
                }),
        ];
    }

    /**
     * 竞品分析
     *
     * @return array
     */
    public static function competingProductAnalyse(): array
    {
        return [
            'productName'                 => self::unit('productName', '竞品名称', true, 'text'),
            'hallFoodNumber'              => self::unit('hallFoodNumber', '堂食客单量', false, 'number', [],
                ['unit' => '单/月']),
            'hallFoodUnitPrice'           => self::unit('hallFoodUnitPrice', '堂食客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'elemNumber'                  => self::unit('elemNumber', '饿了么客单量', false, 'number', [],
                ['unit' => '单/月']),
            'elemUnitPrice'               => self::unit('elemUnitPrice', '饿了么客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'meituanNumber'               => self::unit('meituanNumber', '美团客单量', false, 'number', [],
                ['unit' => '单/月']),
            'meituanUnitPrice'            => self::unit('meituanUnitPrice', '美团客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'shopInnerPhoto'              => self::unit('shopInnerPhoto', '门店图片', true, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_INNER_PHOTO]),
            'dazhongPhoto'                => self::unit('dazhongPhoto', '大众点评截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_DAZHONG_PHOTO]),
            'elemPhoto'                   => self::unit('elemPhoto', '饿了么平台截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_ELEM_PHOTO]),
            'meituanPhoto'                => self::unit('meituanPhoto', '美团平台截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_MEITUAN_PHOTO]),
//            'eatInOpenReceiptPhoto'       => self::unit('eatInOpenReceiptPhoto', '堂食开业小票照片', false,
//                'albumCheckbox', [], ["isResource" => true]),
            'eatInGraduationReceiptPhoto' => self::unit('eatInGraduationReceiptPhoto', '堂食结业小票照片', false,
                'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_EAT_IN_GRADUATION_RECEIPT_PHOTO]),
            'specialExplanation'          => self::unit('specialExplanation', '外卖等特殊情况说明', false, 'text'),
        ];
    }

    /**
     * 互补品分析
     *
     * @return array
     */
    public static function complementProductAnalyse(): array
    {
        return [
            // 竞品分析 - 1 , 互补品 - 2
            'productName'                 => self::unit('productName', '互补品名称', true, 'text'),
            'hallFoodNumber'              => self::unit('hallFoodNumber', '堂食客单量', false, 'number', [],
                ['unit' => '单/月']),
            'hallFoodUnitPrice'           => self::unit('hallFoodUnitPrice', '堂食客单价格', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'elemNumber'                  => self::unit('elemNumber', '饿了么客单量', false, 'number', [],
                ['unit' => '单/月']),
            'elemUnitPrice'               => self::unit('elemUnitPrice', '饿了么客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'meituanNumber'               => self::unit('meituanNumber', '美团客单量', false, 'number', [],
                ['unit' => '单/月']),
            'meituanUnitPrice'            => self::unit('meituanUnitPrice', '美团客单价', false, 'number', [],
                ['money' => true, 'unit' => '元/单']),
            'shopInnerPhoto'              => self::unit('shopInnerPhoto', '门店图片', true, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_INNER_PHOTO]),
            'dazhongPhoto'                => self::unit('dazhongPhoto', '大众点评截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_DAZHONG_PHOTO]),
            'elemPhoto'                   => self::unit('elemPhoto', '饿了么平台截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_ELEM_PHOTO]),
            'meituanPhoto'                => self::unit('meituanPhoto', '美团平台截图', false, 'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_SHOP_MEITUAN_PHOTO]),
//            'eatInOpenReceiptPhoto'       => self::unit('eatInOpenReceiptPhoto', '堂食开业小票照片', false,
//                'albumCheckbox', [], ["isResource" => true]),
            'eatInGraduationReceiptPhoto' => self::unit('eatInGraduationReceiptPhoto', '堂食结业小票照片', false,
                'albumCheckbox', [],
                ["isResource" => true, "position" => UploadFileResourceEnum::PRODUCT_EAT_IN_GRADUATION_RECEIPT_PHOTO]),
            'specialExplanation'          => self::unit('specialExplanation', '外卖等特殊情况说明', false, 'text'),
        ];
    }


    /**
     * 工程条件
     *
     * @return array
     */
    public static function engineeringCondition(): array
    {
        return [
            'decorationShopType'      => self::unit('decorationShopType', '装修店型', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::DECORATION_SHOP_TEXT)),
            'doorWidth'               => self::unit('doorWidth', '门宽', true, 'number', [],
                ['unit' => 'm']),
            'doorHeadWidth'           => self::unit('doorHeadWidth', '门头牌匾横向长度', true, 'number', [],
                ['unit' => 'm']),
            'shopWidth'               => self::unit('shopWidth', '店宽', true, 'number', [],
                ['unit' => 'm']),
            'floorHeight'             => self::unit('floorHeight', '层高', true, 'number', [],
                ['unit' => 'm']),
            'depth'                   => self::unit('depth', '进深', true, 'number', [], ['unit' => 'm']),
            'doorDepthWidthPhoto'     => self::unit('doorDepthWidthPhoto', '门宽进深量尺图片', true, 'albumCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::DOOR_DEPTH_WIDTH_PHOTO
                    ];
                    if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                    }
                    return $extFieldAttribute;
                }),
            'area'                    => self::unit('area', '面积', true, 'number', [], ['unit' => '㎡']),
            'openDoorType'            => self::unit('openDoorType', '铺位开门形式', true, 'radio',
                SiteLocationEnum::getOptionsByConst(OpenShopSiteLocationModel::OPEN_DOOR_TYPES)),
            'isChangeDoor'            => self::unit('isChangeDoor', '是否可改为玻璃开门', false, 'radio', SiteLocationEnum::getOptionsByConst(OpenShopSiteLocationModel::IS_CHANGE_DOOR_MAPPING), function () {
                if (SiteLocationService::$siteLocationModel->openDoorType != OpenShopSiteLocationModel::OPEN_DOOR_TYPE_GLASS) {
                    $extFieldAttribute = ["required" => true, "display"  => "block"];
                } else {
                    $extFieldAttribute = ["required" => false, "display" => "none"];
                }
                return $extFieldAttribute;
            }),
            'wallTileUsedOld'         => self::unit('wallTileUsedOld', '地砖墙砖装修利旧', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::WALL_TAIL_USED_OLD_MAP)),
            'wallTileUsedOldPhoto'    => self::unit('wallTileUsedOldPhoto', '门店内装修利旧实拍图', false, 'albumCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::WALL_TAIL_USED_OLD_PHOTO
                    ];
                    if (SiteLocationService::$siteLocationModel->wallTileUsedOld > 0) {
                        if (SiteLocationService::$siteLocationModel->wallTileUsedOld == SiteLocationEnum::WALL_TAIL_USED_OLD_OK) {
                            $extFieldAttribute = array_merge($extFieldAttribute, [
                                "required" => true,
                                "display"  => "block"
                            ]);
                        } else {
                            $extFieldAttribute = array_merge(
                                $extFieldAttribute,
                                ["required" => false, "display" => "none"]
                            );
                        }
                    } else {
                        $extFieldAttribute = array_merge(
                            $extFieldAttribute,
                            ["required" => false, "display" => "none"]
                        );
                    }
                    return $extFieldAttribute;
                }),
            'isCapacityIncrease'      => self::unit('isCapacityIncrease', '电量增容', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_CAPACITY_INCREASE_TEXT)),
            'capacityIncreaseFee'     => self::unit('capacityIncreaseFee', '电量增容费', false, 'number', [],
                ['unit' => '元', 'money' => false, 'box' => true]),
            'exhaustAirVolume'        => self::unit('exhaustAirVolume', '排风量', true, 'number', [], function () {
                $extFieldAttribute = ['unit' => 'm³/h'];
                if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                }
                return $extFieldAttribute;
            }),
            'isExhaustReconstruction' => self::unit('isExhaustReconstruction', '排风改造', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_EXHAUST_RECONSTRUCTION_TEXT), function () {
                    $extFieldAttribute = ["required" => true];
                    if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                    }
                    return $extFieldAttribute;
                }),
            'upperWaterDiameter'      => self::unit('upperWaterDiameter', '上水管径', true, 'number', [], function () {
                $extFieldAttribute = ["required" => true, 'unit' => 'mm'];
                if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                }
                return $extFieldAttribute;
            }),
            'lowerWaterDiameter'      => self::unit('lowerWaterDiameter', '下水管径', true, 'number', [], function () {
                $extFieldAttribute = ["required" => true, 'unit' => 'mm'];
                if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                }
                return $extFieldAttribute;
            }),
            'isReformWater'           => self::unit('isReformWater', '水管改造', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_REFORM_WATER_TEXT), function () {
                    $extFieldAttribute = ["required" => true];
                    if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                    }
                    return $extFieldAttribute;
                }),
            'airConditionerCType'     => self::unit('airConditionerCType', '空调', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::AIR_CONDITIONER_TYPE_TEXT), function () {
                    $extFieldAttribute = ["required" => true];
                    if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                    }
                    return $extFieldAttribute;
                }),
            'isFireControl'           => self::unit('isFireControl', '消防', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_FIRE_CONTROL_TEXT), function () {
                    $extFieldAttribute = ["required" => true];
                    if (SiteLocationService::$siteLocationModel->isSolicitBusinessManager) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                    }
                    return $extFieldAttribute;
                }),
            'adSpaceNumber'           => self::unit('adSpaceNumber', '广告位', false, 'number', [],
                ['unit' => '个']),
            'electricityConsumption'  => self::unit('electricityConsumption', '用电量', true, 'number', [],
                ['unit' => 'kw']),
        ];
    }

    /**
     * 客群分析
     *
     * @return array
     */
    public function customerAnalyse(): array
    {
        return [
            // 客群分析表
            'time'                        => self::unit('time', '当前时间', false, 'text', [],
                ['display' => 'none']),
            'week'                        => self::unit('week', '星期', false, 'text', [], ['display' => 'none']),
            'dateType'                    => self::unit('dateType', '日期类型', false, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::DATE_TYPE_TEXT), function () {
                    if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                        return self::unit('dateType', '日期类型', false, 'radio',
                            SiteLocationEnum::getOptionsByConst(SiteLocationEnum::DATE_TYPE_TEXT),
                            ['icon' => '', 'disabled' => false]);
                    } else {
                        return ['icon' => '', 'disabled' => false];
                    }
                }
            ),
            'weather'                     => self::unit('weather', '天气', false, 'text', [], function () {
                if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                    return self::unit('weather', '天气', false, 'text', [],
                        ['disabled' => false]);
                } else {
                    return ['icon' => '', 'disabled' => false];
                }
            }
            ),
            'temperature'                 => self::unit('temperature', '温度', false, 'text', [],
                ['display' => 'none']),
            'afternoonNumber'             => self::unit('afternoonNumber', '午间时段人数', false, 'number'),
            'afternoonYoungProportion'    => self::unit('afternoonYoungProportion', '年轻客群占比', false, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT)),
            'afternoonTeaNumber'          => self::unit('afternoonTeaNumber', '下午茶时段人数', false, 'number'),
            'afternoonTeaYoungProportion' => self::unit('afternoonTeaYoungProportion', '年轻客群占比', false, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT)),
            'nightNumber'                 => self::unit('nightNumber', '晚间时段人数', false, 'number'),
            'nightYoungProportion'        => self::unit('nightYoungProportion', '年轻客群占比', false, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT)),
            'nightSnackNumber'            => self::unit('nightSnackNumber', '宵夜时段人数', false, 'number'),
            'nightSnackYoungProportion'   => self::unit('nightSnackYoungProportion', '年轻客群占比', false, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT)),
            'afternoonPhoto'              => self::unit('afternoonPhoto', '午市时段图片', false, 'cameraCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::AFTERNOON_MARKET_PHOTO,
                    ];
                    if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["input" => "albumCheckbox"]);
                    }
                    return $extFieldAttribute;
                }),
            'afternoonTeaPhoto'           => self::unit('afternoonTeaPhoto', '下午茶时段图片', false, 'cameraCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::AFTERNOON_TEA_MARKET_PHOTO,
                    ];
                    if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["input" => "albumCheckbox"]);
                    }
                    return $extFieldAttribute;
                }),
            'nightPhoto'                  => self::unit('nightPhoto', '晚市时段图片', false, 'cameraCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::NIGHT_MARKET_PHOTO,
                    ];
                    if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["input" => "albumCheckbox"]);
                    }
                    return $extFieldAttribute;
                }),
            'nightSnackPhoto'             => self::unit('nightSnackPhoto', '夜宵时段图片', false, 'cameraCheckbox', [],
                function () {
                    $extFieldAttribute = [
                        "isResource" => true,
                        "position"   => UploadFileResourceEnum::NIGHT_SNACK_MARKET_PHOTO,
                    ];
                    if (SiteLocationService::$siteLocationModel->messageFrom == SiteLocationEnum::MESSAGE_FROM_TYPE_3) {
                        $extFieldAttribute = array_merge($extFieldAttribute, ["input" => "albumCheckbox"]);
                    }
                    return $extFieldAttribute;
                })
        ];
    }

    /**
     * @param string $field
     * @return array
     */
    public static function getShopAttributeField(string $field): array
    {
        $data       = [];
        $categoryId = 0;
        foreach (self::$shopAttributeData as $v) {
            switch ($field) {
                case 'shopType':// 店型
                    $categoryId = SiteLocationEnum::CATEGORY_ID_2;
                    break;
                case 'siteSelection':// 选址场景
                    $categoryId = SiteLocationEnum::CATEGORY_ID_3;
                    break;
                case 'sellingCategory':// 售卖品类
                    $categoryId = SiteLocationEnum::CATEGORY_ID_4;
                    break;
                case 'menuLevel':// 产品定价
                    $categoryId = SiteLocationEnum::CATEGORY_ID_11;
                    break;
                case 'posLine':// 点餐动线
                    $categoryId = SiteLocationEnum::CATEGORY_ID_6;
                    break;
            }
            if ($categoryId && $v['id'] == $categoryId && $v['value']) {
                foreach ($v['value'] as $value) {
                    if ($field == 'menuLevel' && strpos($value['name'], '其他') !== false) {// 菜单定金中不需要“其他”选项
                        continue;
                    }
                    $data[$value['id']] = $value['name'];
                }
            }
        }
        return $data;
    }

    /**
     * 项目信息
     *
     * @return array
     */
    public static function itemInfo(): array
    {
        return [
            // 项目信息


            'shopType'      => self::unit(
                'shopType', '店型', true, 'radio',
                SiteLocationEnum::getOptionsByConst(self::getShopAttributeField('shopType'))
            ),
            'siteSelection' => self::unit(
                'siteSelection', '选址场景', true, 'checkbox',
                SiteLocationEnum::getOptionsByConst(self::getShopAttributeField('siteSelection')), ['max' => 99]
            ),
            'recommendType'    => self::unit('recommendType', '铺位推荐方式', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RECOMMEND_TYPES)),
            'messageFrom'    => self::unit('messageFrom', '门店信息来源', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::MESSAGE_FROM_TYPE_TEXT)),
            'longitude'      => self::unit('longitude', '门店经度', true, 'text', [],
                ['display' => 'none']),
            'latitude'       => self::unit('latitude', '门店纬度', true, 'text', [],
                ['display' => 'none']),
            'siteAddress'    => self::unit('siteAddress', '经纬度地址', true, 'map'),
            'nearbyShopName' => self::unit('nearbyShopName', '附近门店', false, 'text', [],
                ['disabled' => true]),
            'nearbyRange'    => self::unit('nearbyRange', '附近门店距离', false, 'text', [],
                ['disabled' => true, 'unit' => 'km']),


            'nearbyPlaceHolderName'  => self::unit('nearbyPlaceHolderName', '附近点位', false, 'text', [],
                ['disabled' => true]),
            'nearbyPlaceHolderRange' => self::unit('nearbyPlaceHolderRange', '附近点位距离', false, 'text', [],
                ['disabled' => true, 'unit' => 'km']),

            'nearbyShopCode' => self::unit('nearbyShopCode', '门店编号', false, 'text', [],
                ['disabled' => true, 'unit' => 'km', 'display' => 'none']),
            'cityArea'       => self::unit('cityArea', '选择城市', true, 'address', [],
                ['disabled' => true]),
            'cityType'       => self::unit('cityType', '城市等级', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CITY_TYPE_LEVEL_TEXT),
                ['disabled' => true, 'icon' => '']),
            'town'       => self::unit('town', '乡镇', true, 'text', [],
                ['disabled' => true, 'icon' => '']),
            'address'        => self::unit('address', '门店地址', true, 'textarea', [],
                ["placeholder" => "请输入包含省市区及详细门牌号的地址"]),
            'selectTime'     => self::unit('selectTime', '选址日期', true, 'datetime', [],
                ['icon' => 'arrow-right']),
            'provinceCode'   => self::unit('provinceCode', '省份', false, 'text'),
            'cityCode'       => self::unit('cityCode', '市', false, 'text', [],
                ['display' => 'none']),
            'areaCode'       => self::unit('areaCode', '区', false, 'text', [],
                ['display' => 'none']),
            'shopName'       => self::unit('shopName', '门店名称', false, 'textarea', [], function () {
                return [
                    "required"    => true,
                    "placeholder" => "示例：夸父炸串（河南鹤壁淇滨万达店），（）括号内，门店名称不要带华北、华东、省、市、区、镇等字以及特殊符号",
                    'desc'        => '示例：夸父炸串（河南鹤壁淇滨万达店）' . PHP_EOL . '注意📢：（）括号内，门店名称不要带华北、华东、省、市、区、镇等字以及特殊符号' . PHP_EOL . '【商场店】' . PHP_EOL . '❌错误示例：夸父炸串（华东浙江省嘉兴市平湖区吾悦广场店）' . PHP_EOL . '✅正确示例：夸父炸串（浙江嘉兴平湖吾悦广场店），夸父炸串（北京朝阳大悦城店）' . PHP_EOL . '【街边店】' . PHP_EOL . '❌错误示例：夸父炸串（陕西省榆林市榆阳区金榆中路店）' . PHP_EOL . '✅正确示例：夸父炸串（陕西榆林榆阳金榆中路店），夸父炸串（上海浦东世纪汇风情街店）' . PHP_EOL . '如不按照规定要求填写会对筹备及后续流程造成困难，填写错误会被驳回修改，造成不必要的时间浪费。'
                ];
            }),
            // 图片信息
            'heatMap'        => self::unit('heatMap', '百度地图热力图', true, 'albumCheckbox', [], [
                "isResource" => true,
                "position"   => UploadFileResourceEnum::PROJECT_MESSAGE_BAIDU_HEAT_MAP,
                "descImg"    => "https://file.51kuafu.com/b0/cd/5a8ab1c745aba3b5707a8bf8aed499030934a109b171657bc2fa77b9be74.jpg"
            ]),
        ];
    }

    /**
     * 租赁信息
     *
     * @return array
     */
    public static function leaseContractInfo(): array
    {
        return [
            'leaseFiles'         => self::unit('leaseFiles', '租赁合同文件', true, 'fileUpload', [], ["descImg" => "https://file.51kuafu.com/87/b2/adb95aafd5553708f9f37882496496f3a019665b64a5387255aeea403496.png", 'desc' => '注意事项' . PHP_EOL . '支持图片上传和附件上传，租赁合同信息需要体现：' . PHP_EOL . '1 合同双方信息' . PHP_EOL . '2 租赁合同房屋为止面积信息' . PHP_EOL . '3 承租方式和租期' . PHP_EOL . '4 租金信息' . PHP_EOL . '5 押金以及其他费用信息']),
            'signatureTime'      => self::unit('signatureTime', '签署时间', true, 'datetime', [], ['icon' => 'arrow-right']),
            'ctRentType'         => self::unit('ctRentType', '计租方式', true, 'radio', SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RENT_TYPE_TEXT), []),
            'ctFixedRent'        => self::unit('ctFixedRent', '固定租金', true, 'number', [], ['unit' => '元/年', 'box' => true]),
            'ctRemind'           => self::unit('ctRemind', '提点百分比', true, 'number', [], ['unit' => '%']),
            'ctRentPaymentCycle' => self::unit('ctRentPaymentCycle', '租金支付周期', true, 'radio', SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RENT_PAYMENT_TEXT), []),
            'ctDeposit'          => self::unit('ctDeposit', '押金', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctLeaseTerm'        => self::unit('ctLeaseTerm', '租期', true, 'number', [], ['unit' => '月']),
            'ctStartTime'        => self::unit('ctStartTime', '合同开始时间', true, 'datetime', [], ['icon' => 'arrow-right']),
            'ctEndTime'          => self::unit('ctEndTime', '合同结束时间', true, 'datetime', [], ['icon' => 'arrow-right']),
            'ctRentFreePeriod'   => self::unit('ctRentFreePeriod', '免租期', true, 'number', [], ['unit' => '天']),
            'ctPropertyFee'      => self::unit('ctPropertyFee', '物业费', true, 'number', [], ['unit' => '元/年', 'box' => true]),
            'ctMobilizationFee'  => self::unit('ctMobilizationFee', '进场费', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctTransferFee'      => self::unit('ctTransferFee', '转让费', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctBond'             => self::unit('ctBond', '门店保证金', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctManageFee'        => self::unit('ctManageFee', '管理费', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctSponsorshipFee'   => self::unit('ctSponsorshipFee', '赞助费', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctPromotionFee'     => self::unit('ctPromotionFee', '推广费', true, 'number', [], ['unit' => '元', 'box' => true]),
            'ctOtherFee'         => self::unit('ctOtherFee', '其他费用', true, 'number', [], ['unit' => '元', 'box' => true]),
            'expenseDifferDesc'  => self::unit('expenseDifferDesc', '费用不一致说明', false, 'textarea', [], []),
        ];
    }


    /**
     * 租赁信息
     *
     * @return array
     */
    public static function takeOutEstimate(): array
    {
        return [
            'wmHeatMap'              => self::unit('wmHeatMap', '外卖热力图', false, 'heatmap', [],
                ['requestData' => ['url' => config('app.url') . 'openShop/feishu/siteLocation/preserveHeatMap', 'methods' => 'POST', 'data' => ['orderNo' => SiteLocationService::$siteLocationModel->orderNo]], 'zoom' => 15, 'lng' => SiteLocationService::$siteLocationModel->longitude, 'lat' => SiteLocationService::$siteLocationModel->latitude, 'dataUrl' => '', 'background' => '', "isResource" => true, "position" => UploadFileResourceEnum::TAKE_OUT_HEATMAP, "disabled" => true, 'desc' => "外卖热力图说明：点位附近3km全品类门店月销量热力图" . PHP_EOL . "外卖销量预估说明：按照预估订单量乘以系数0.8和1.2，取值外卖销量区间值" . PHP_EOL . "外卖销量预估：按照单据30元估算月实收区间值"]),
            'takeOutDoubleSalesVolume'      => self::unit('takeOutDoubleSalesVolume', '双平台外卖销量预估', false, 'text', [], ["disabled" => true, 'unit' => '单', 'desc' => "外卖热力图说明：点位附近3km全品类门店月销量热力图" . PHP_EOL . "外卖销量预估说明：按照预估订单量乘以系数0.8和1.2，取值外卖销量区间值" . PHP_EOL . "外卖销量预估：按照单据30元估算月实收区间值"]),
            'takeOutDoubleSalesVolumeReceived'         => self::unit('takeOutDoubleSalesVolumeReceived', '双平台外卖月实收预估', false, 'text', [], ["disabled" => true, 'unit' => '元']),
            'mtSalesVolume'        => self::unit('mtSalesVolume', '美团外卖月销量预估', false, 'text', [], ['unit' => '单', "disabled" => true]),
            'elmSalesVolume'        => self::unit('elmSalesVolume', '饿了么外卖月销量预估', false, 'text', [], ['unit' => '单', "disabled" => true]),

            'kfSalesVolume'           => self::unit('kfSalesVolume', '', false, 'table', [], ["disabled" => true, 'header' => [
                [
                    'key'   => 'shopName',
                    'label' => '门店名称',
                ],
                [
                    'key'   => 'distance',
                    'label' => '距离',
                    'pixel' => 60,
                ],
                [
                    'key'   => 'mtElm',
                    'label' => '美团/饿了么/双平台',
                ]
            ]]),
            'mtFriedGoods'           => self::unit('mtFriedGoods', '', false, 'table', [], ["disabled" => true, 'header' => [
                [
                    'key'   => 'shopName',
                    'label' => '门店',
                ],
                [
                    'key'   => 'distance',
                    'label' => '距离',
                    'pixel' => 60,
                ],
                [
                    'key'   => 'mt',
                    'label' => '美团',
                    'pixel' => 70,
                ]
            ]]),
            'elmFriedGoods'           => self::unit('elmFriedGoods', '', false, 'table', [], ["disabled" => true, 'header' => [
                [
                    'key'   => 'shopName',
                    'label' => '门店',
                ],
                [
                    'key'   => 'distance',
                    'label' => '距离',
                    'pixel' => 60,
                ],
                [
                    'key'   => 'elm',
                    'label' => '饿了么',
                    'pixel' => 70,
                ]
            ]]),
        ];
    }

    /**
     * 商务条件
     *
     * @return array
     */
    public static function businessConditions(): array
    {
        return [
            // 商务条件
            'rentType'                    => self::unit('rentType', '计租方式', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RENT_TYPE_TEXT)),
            'fixedRent'                   => self::unit('fixedRent', '固定租金', true, 'number', [], function () {
                $extFieldAttribute = ['unit' => '元/年', 'money' => true, 'box' => true];
                if (
                    SiteLocationService::$siteLocationModel->rentType > 0
                    && SiteLocationService::$siteLocationModel->rentType != SiteLocationEnum::RENT_TYPE_2
                    && empty(SiteLocationService::$siteLocationModel->fixedRent)
                ) {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => true]);
                } else {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                }
                return $extFieldAttribute;
            }),
            'remind'                      => self::unit('remind', '提点百分比', true, 'number', [], function () {
                $extFieldAttribute = ['unit' => '%'];
                if (
                    SiteLocationService::$siteLocationModel->rentType > 0
                    && SiteLocationService::$siteLocationModel->rentType != SiteLocationEnum::RENT_TYPE_1
                    && empty(SiteLocationService::$siteLocationModel->remind)
                ) {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => true]);
                } else {
                    $extFieldAttribute = array_merge($extFieldAttribute, ["required" => false]);
                }
                return $extFieldAttribute;
            }),
            'rentPaymentCycle'            => self::unit('rentPaymentCycle', '租金支付周期', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RENT_PAYMENT_TEXT)),
            'deposit'                     => self::unit('deposit', '押金', true, 'number', [],
                ['unit' => '元', 'money' => false, 'box' => true]),
            'leaseTerm'                   => self::unit('leaseTerm', '租期', true, 'number', [],
                ['unit' => '月']),
            'rentFreePeriod'              => self::unit('rentFreePeriod', '免租期', true, 'number', [],
                ['unit' => '天']),


            'warehouseFixedRent'                     => self::unit('warehouseFixedRent', '年固定租金', true, 'number', [],
                ['unit' => '元', 'money' => false, 'box' => true]),
            'warehouseRentPaymentCycle'            => self::unit('warehouseRentPaymentCycle', '租金支付周期', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::RENT_PAYMENT_TEXT)),
            'warehouseDeposit'                     => self::unit('warehouseDeposit', '押金', true, 'number', [],
                ['unit' => '元', 'money' => false, 'box' => true]),
            'warehouseLeaseTerm'                   => self::unit('warehouseLeaseTerm', '租期', true, 'number', [],
                ['unit' => '月']),
            'warehouseRentFreePeriod'              => self::unit('warehouseRentFreePeriod', '免租期', true, 'number', [],
                ['unit' => '天']),

            'caseRegisterType'            => self::unit('caseRegisterType', '收银机', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CASE_REGISTER_TEXT)),
            'cashInfoPhoto'               => self::unit('cashInfoPhoto', '收银机说明文件', false, 'albumCheckbox', [], [
                "isResource" => true,
                "position"   => UploadFileResourceEnum::THE_CASH_REGISTER_PHOTO
            ]),
            'waterFee'                    => self::unit('waterFee', '水费', false, 'number', [],
                ['unit' => '元/吨', 'money' => true, 'box' => true]),
            'electricityFee'              => self::unit('electricityFee', '电费', false, 'number', [],
                ['unit' => '元/度', 'money' => true, 'box' => true]),
            'propertyFee'                 => self::unit('propertyFee', '物业费', false, 'number', [],
                ['unit' => '元/年', 'money' => false, 'box' => true]),
            'mobilizationFee'             => self::unit('mobilizationFee', '进场费', false, 'number', [],
                ['money' => false, 'box' => true]),
            'mobilizationMobile'          => self::unit('mobilizationMobile', '进场联系人', false, 'text'),
            'mobilizationFeeDesc'         => self::unit('mobilizationFeeDesc', '进场费说明', false, 'textarea'),
            'transferFee'                 => self::unit('transferFee', '转让费', false, 'number', [],
                ['money' => false, 'box' => true]),
            'bond'                        => self::unit('bond', '门店保证金', false, 'number', [],
                ['money' => false, 'box' => true]),
            'manageFee'                   => self::unit('manageFee', '管理费', false, 'number', [],
                ['money' => false, 'box' => true]),
            'sponsorshipFee'              => self::unit('sponsorshipFee', '赞助费', false, 'number', [],
                ['money' => false, 'box' => true]),
            'promotionFee'                => self::unit('promotionFee', '推广费', false, 'number', [],
                ['money' => false, 'box' => true]),
            'otherFee'                    => self::unit('otherFee', '其他费用', false, 'number', [],
                ['money' => false, 'box' => true]),
            'otherFeeDesc'                => self::unit('otherFeeDesc', '其他费用说明', false, 'textarea'),

            'shopFacadeType'       => self::unit(
                'shopFacadeType', '门面类型', true,
                'radio', SiteLocationEnum::getOptionsByConst(SiteLocationEnum::SHOP_FACED_TYPE)
            ),
            /*********   营业执照   *********/
            'handleBusinessLicense'       => self::unit(
                'handleBusinessLicense', '营业执照办理', true,
                'radio', SiteLocationEnum::getOptionsByConst(SiteLocationEnum::HANDLE_BUSINESS_LICENSE_MAP)
            ),


            /*********   食品安全许可证   *********/
            'handleFoodLicense'           => self::unit(
                'handleFoodLicense', '食品经营许可证办理', true,
                'radio', SiteLocationEnum::getOptionsByConst(SiteLocationEnum::HANDLE_FOOD_LICENSE_MAP)
            ),

            // 'historyFoodLicensePhoto' => self::unit(
            //     'historyFoodLicensePhoto', '历史食品安全许可证照片', false,
            //     'albumCheckbox', [], [
            //         "required"   => false,
            //         "display"    => "block",
            //         "isResource" => true,
            //         "position"   => UploadFileResourceEnum::LICENSE_FOOD_PHOTO,
            //     ]
            // ),

            'doubleWaimai' => self::unit(
                'doubleWaimai', '外卖双平台上线', false, 'checkbox',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::DOUBLE_WAIMAI), ['max' => 2]
            ),

            'douyin' => self::unit(
                'douyin', '抖音平台上线', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_REFORM_WATER_TEXT)
            ),

            /*********   备注说明   *********/
            'licenseRemark'           => self::unit(
                'licenseRemark', '证照办理异常说明', false,
                'textarea', [], ["placeholder" => "有无下证风险 ，预计下证时间"]
            ),

            'historyBusinessLicensePhoto' => self::unit(
                'historyBusinessLicensePhoto', '图片附件', false,
                'albumCheckbox', [], [
                    "isResource" => true,
                    "position"   => UploadFileResourceEnum::LICENSE_BUSINESS_PHOTO,
                    "required"   => false, //选址2.0.1优化
                    "display"    => "block"
                ]
            ),

            'franchiseesKnow' => self::unit(
                'franchiseesKnow', '证照办理信息加盟商知晓', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::IS_FIRE_CONTROL_TEXT), ["placeholder" => "请选择"]
            ),
            'leaseMobile'             => self::unit('leaseMobile', '联系方式', true, 'text'),
            'leaseName'               => self::unit('leaseName', '联系人姓名', true, 'text'),
            'leaseWeChat'             => self::unit('leaseWeChat', '微信号', false, 'text'),
            'infoPhoto'               => self::unit('infoPhoto', '营业资料', false, 'albumCheckbox', [], [
                "isResource" => true,
                "position"   => UploadFileResourceEnum::BUSINESS_INFO_PHOTO,
            ]),
        ];
    }

    /**
     * 门店照片
     *
     * @return array
     */
    public static function locationsPhoto(): array
    {
        return [
            //选址2.2优化新增
            'shopModelType'         => self::unit(
                'shopModelType',
                '门店类型',
                true,
                'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::SHOP_MODEL_TYPE_MAPPING),
                ["disabled" => true]
            ),
            'openingStatus'         => self::unit(
                'openingStatus',
                '开业状态',
                true,
                'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::OPENING_STATUS_MAP),
                function () {
                    if (!in_array(SiteLocationService::$siteLocationModel->shopModelType, [
                        SiteLocationEnum::SHOP_MODEL_TYPE_MALL
                    ])) {
                        return [
                            "display"  => "none",
                            "required" => false
                        ];
                    } else {
                        return [];
                    }
                }
            ),
            'belongFloor'    => self::unit(
                'belongFloor',
                '铺位所属楼层',
                true,
                'radio',
                SiteLocationEnum::getOptionsByConst(MallSettleInShopInfoModel::getEachFloorNameByMallId(SiteLocationService::$siteLocationModel->mallId)),
                function () {
                    //获得楼层筛选
                    return [
                        'customInput' => true,
                        'bottomText'  => '查看楼层所属店铺 >',
                        'mallId'      => SiteLocationService::$siteLocationModel->mallId,
                    ];
                }
            ),
            'recommendFloor' => self::unit(
                'recommendFloor',
                '推荐楼层',
                false,
                'radio',
                [],
                function () {
                    //获得推荐楼层
                    return [
                        'customInput' => true,
                        'bottomText'  => '查看楼层所属店铺 >',
                        'mallId'      => SiteLocationService::$siteLocationModel->mallId,
                        'icon'        => '',
                        'disabled'    => true
                    ];
                }
            ),
            'shopVideo'             => self::unit('shopVideo', '动线讲解', true, 'video', [], function () {
                $customExtFields = array_merge(
                    ["isResource" => true, "position" => UploadFileResourceEnum::SHOP_ADDRESS_SHOP_VIDEO],
                    ["descVideo" => "https://file.51kuafu.com/80/a8/72ae6611c92bb193da32c56b504141cbeb531ee49652be42f60bb3f149ae.mp4"],
                    ['showTip' => true]
                );
                switch (SiteLocationService::$siteLocationModel->shopModelType) {
                    case SiteLocationEnum::SHOP_MODEL_TYPE_MALL:
                        $customExtFields = array_merge(
                            $customExtFields,
                            ["desc" => "对着动线图拍视频介绍点位位置及客流动线"]
                        );
                        break;
                    case SiteLocationEnum::SHOP_MODEL_TYPE_COMMUNITY_STREET:
                    case SiteLocationEnum::SHOP_MODEL_TYPE_COMMUNITY_SCHOOL:
                    case SiteLocationEnum::SHOP_MODEL_TYPE_SCHOOL_CANTEEN:
                    case SiteLocationEnum::SHOP_MODEL_TYPE_SCHOOL_STREET:
                    case SiteLocationEnum::SHOP_MODEL_TYPE_SCENIC_SPOT_INSIDE:
                        $customExtFields = array_merge(
                            $customExtFields,
                            ["desc" => "介绍门店周边客流动线，走向店内视频"]
                        );
                        break;
                }
                return $customExtFields;
            }),
            'floorExplanationVideo' => self::unit(
                'floorExplanationVideo',
                '楼层讲解',
                true,
                'video',
                [],
                function () {
                    $customExtFields = array_merge(
                        ["isResource" => 1, "position" => UploadFileResourceEnum::FLOOR_EXPLANATION_VIDEO],
                        ["descVideo" => "https://file.51kuafu.com/92/4b/5a17c611567ad34560894e99cd9bb62ecfbd83764fb7fce3f748a9afc282.mp4"]
                    );
                    switch (SiteLocationService::$siteLocationModel->shopModelType) {
                        case SiteLocationEnum::SHOP_MODEL_TYPE_MALL:
                            $customExtFields = array_merge(
                                $customExtFields,
                                ["desc" => "围绕楼层转一圈介绍客流动线及相关餐饮业态"]
                            );
                            break;
                        default:
                            $customExtFields = array_merge(
                                $customExtFields,
                                [
                                    "required" => false,
                                    "display"  => "none"
                                ]
                            );
                            break;
                    }
                    return $customExtFields;
                }
            ),
            'peripheralVideo'       => self::unit(
                'peripheralVideo',
                '周边视频',
                true,
                'video',
                [],
                function () {
                    $customExtFields = array_merge(
                        ["isResource" => true, "position" => UploadFileResourceEnum::PERIPHERAL_VIDEO],
                        ["descVideo" => "https://file.51kuafu.com/89/ab/703e0f0b8a349efb53ca51eba744a4040a0073b06627c4f23e523f02e100.mp4"]
                    );
                    switch (SiteLocationService::$siteLocationModel->shopModelType) {
                        case SiteLocationEnum::SHOP_MODEL_TYPE_MALL:
                            $customExtFields = array_merge(
                                $customExtFields,
                                ["desc" => "商场周边交通、社区、写字楼等视频介绍"]
                            );
                            break;
                        case SiteLocationEnum::SHOP_MODEL_TYPE_COMMUNITY_STREET:
                        case SiteLocationEnum::SHOP_MODEL_TYPE_COMMUNITY_SCHOOL:
                            $customExtFields = array_merge(
                                $customExtFields,
                                ["desc" => "视频讲解门店周边交通、住宅小区、写字楼、学校等视客流驱动因素"]
                            );
                            break;
                        default:
                            $customExtFields = array_merge(
                                $customExtFields,
                                [
                                    "required" => false,
                                    "display"  => "none"
                                ]
                            );
                            break;
                    }
                    if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                        $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                    }
                    return $customExtFields;
                }
            ),
            'shopInVideo'           => self::unit(
                'shopInVideo',
                '店内视频',
                true,
                'video',
                [],
                function () {
                    $customExtFields = array_merge(
                        ["desc" => "店内环境介绍", "isResource" => 1, "position" => UploadFileResourceEnum::SHOP_IN_VIDEO],
                        ["descVideo" => "https://file.51kuafu.com/d3/58/40b8f71a0779676cd70be9e6d6bbccf5beada810cd29590bee2246662d99.mp4"]
                    );
                    if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                        $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                    }
                    return $customExtFields;
                }
            ),
            'leftPhoto'             => self::unit('leftPhoto', '左视图', true, 'albumCheckbox', [], function () {
                $customExtFields = [
                    "isResource" => 1,
                    "position"   => UploadFileResourceEnum::SHOP_ADDRESS_LEFT_PHOTO,
                    "desc"       => "请站在店铺的左前方距离5-10米处拍摄店铺及其右侧的商业环境",
                    "descImg"    => "https://file.51kuafu.com/2e/06/c00fb7f2bc5feb08c35e5a8ec35ac51266f1f863b1cfe59a47eea0419ab8.jpg"
                ];
                if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                    $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                }
                return $customExtFields;
            }),
            'rightPhoto'            => self::unit('rightPhoto', '右视图', true, 'albumCheckbox', [], function () {
                $customExtFields = [
                    "isResource" => true,
                    "position"   => UploadFileResourceEnum::SHOP_ADDRESS_RIGHT_PHOTO,
                    "desc"       => "请站在店铺的右前方距离5-10米处拍摄店铺及其左侧的商业环",
                    "descImg"    => "https://file.51kuafu.com/ee/9f/2b363c7d790a263e61717a9fc190da78f43ab75a18b5597db0f64b100ac9.jpg"
                ];
                if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                    $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                }
                return $customExtFields;
            }),
            'frontPhoto'            => self::unit('frontPhoto', '正视图', true, 'albumCheckbox', [], function () {
                $customExtFields = [
                    "isResource" => true,
                    "position"   => UploadFileResourceEnum::SHOP_ADDRESS_FRONT_PHOTO,
                    "desc"       => "请站在店铺的前方距离5-10米处拍摄店铺的正面",
                    "descImg"    => "https://file.51kuafu.com/39/e7/35efb2bdfd4a1fb7d3b2499ef5f58b5c028a69e95cae26f4743422f43ad8.jpg"
                ];
                if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                    $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                }
                return $customExtFields;
            }),
            'innerPhoto'            => self::unit('innerPhoto', '店内照片', true, 'albumCheckbox', [], function () {
                return [
                    "isResource" => true,
                    "position"   => UploadFileResourceEnum::SHOP_ADDRESS_SHOP_INNER_PHOTO,
                    "desc"       => "请进入店内对门店内部情况进行拍摄",
                    "descImg"    => "https://file.51kuafu.com/68/01/a8e7c83170eb5c9121c342dda71abc7fa9314f10a24dfb016f1b5c9497bb.jpg"
                ];
            }),
            'panoramaPhoto'         => self::unit('panoramaPhoto', '远景图', true, 'albumCheckbox', [], function () {
                $customExtFields = [
                    "isResource" => true,
                    "position"   => UploadFileResourceEnum::SHOP_ADDRESS_PANORAMA_PHOTO,
                    'unit'       => '上传180°长图片',
                    "desc"       => "请站在尽可能远的地方使用手机的广角镜头拍摄店铺及其周边环境",
                    "descImg"    => "https://file.51kuafu.com/eb/02/80c5e4fe8519642a06802239d9cad86b83a4491c75c5df922de033cc95d6.jpg"
                ];
                if (SiteLocationService::$siteLocationModel->getAttribute("isSolicitBusinessManager")) {
                    $customExtFields = array_merge($customExtFields, ["required" => false, "display" => "none"]);
                }
                return $customExtFields;
            })
        ];
    }

    /**
     * 投资预算配置
     *
     * @return array
     */
    public static function getCapitalBudgeting(): array
    {
        return [
            //投资预算
            'shopManagerCount'            => self::unit('shopManagerCount', '店长数量', true, 'number', [],
                ['unit' => '位']),
            'shopManagerMonthSalary'      => self::unit('shopManagerMonthSalary', '店长月薪', true, 'number', [],
                ['money' => true, 'unit' => '元/月/人', 'box' => true]),
            'shopAssistantCount'          => self::unit('shopAssistantCount', '店员数量', true, 'number', [],
                ['unit' => '位']),
            'shopAssistantMonthSalary'    => self::unit('shopAssistantMonthSalary', '店员月薪', true, 'number', [],
                ['money' => true, 'unit' => '元/月/人', 'box' => true]),
            'waterFeeMonth'               => self::unit('waterFeeMonth', '水费', true, 'number', [],
                ['money' => true, 'unit' => '元/月', 'box' => true]),
            'electricityFeeMonth'         => self::unit('electricityFeeMonth', '电费', true, 'number', [],
                ['money' => true, 'unit' => '元/月', 'box' => true]),
            'rentCost'                    => self::unit('rentCost', '月固定租金', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元/月', 'box' => true]),
            'expenseAllocation'           => self::unit('expenseAllocation', '费用分摊', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元/月', 'box' => true]),

            //-------
            'foodstuffMarginRate'         => self::unit('foodstuffMarginRate', '食材毛利率', true, 'number', [],
                ['unit' => '%']),
            'customerUnitPriceEstimation' => self::unit('customerUnitPriceEstimation', '客单价预估', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::CUSTOMER_UNIT_PRICE_ESTIMATION_MAP)),
            'monthQuantityEstimation'     => self::unit('monthQuantityEstimation', '月订单预估', false, 'number', [],
                ['disabled' => true, 'unit' => '单/月']),
            'monthTurnoverEstimation'     => self::unit('monthTurnoverForecast', '月营业额预估', false, 'number', [],
                ['money' => true, 'disabled' => true]),
            'monthFoodstuffChangeCost'    => self::unit('monthFoodstuffChangeCost', '月食材变动成本', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元/月']),
            //-------

            'monthProfitEstimation' => self::unit('monthProfitEstimation', '月利润预估', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元/月']),

            //---

            'dailyTurnover'             => self::unit('dailyTurnover', '每日营业额', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元/天']),
            'dailySellAtCostOrderCount' => self::unit('dailySellAtCostOrderCount', '每日保本单量', false, 'number', [],
                ['disabled' => true, 'unit' => '单/天']),
            //----

            'totalInvestmentEstimation' => self::unit('totalInvestmentEstimation', '总投资预算', false, 'number', [],
                ['money' => true, 'disabled' => true, 'unit' => '元']),
            'returnCycle'               => self::unit('returnCycle', '回本周期', false, 'number', [],
                ['disabled' => true, 'unit' => '月']),
        ];
    }

    /**
     * 动线说明
     *
     * @return array
     */
    public static function generatrixInfo(): array
    {
        return [
//            'lineMarking'  => self::unit('lineMarking', '动线标注', true, 'fileUpload', [], function () {
//                return array_merge(
//                    [
//                        "isResource" => 1,
//                        "position"   => UploadFileResourceEnum::MOVING_LING_MARKING,
//                        "desc"       => "请使用地图或商场平面图对门店所在位置、人流动线、入口、扶梯进行标注",
//                        "descImg"    => "https://file.51kuafu.com/1d/8a/f83f3c0d4cf950478f8f7072f55a28b1d9eaa2fd2df0e1d947fde7105bd5.png"
//                    ],
//                    in_array(SiteLocationService::$siteLocationModel->siteType, [
//                        SiteLocationEnum::SITE_TYPE_18,
//                        SiteLocationEnum::SITE_TYPE_1,
//                        SiteLocationEnum::SITE_TYPE_2,
//                        SiteLocationEnum::SITE_TYPE_3,
//                        SiteLocationEnum::SITE_TYPE_4
//                    ]) ? ["required" => true] : ["required" => false]);
//            }),
            'lineMarking'  => self::unit('lineMarking', '动线标注', true, 'fileUpload', [], [
                                        "isResource" => 1,
                                        "position"   => UploadFileResourceEnum::MOVING_LING_MARKING,
                                        "desc"       => "请使用地图或商场平面图对门店所在位置、人流动线、入口、扶梯进行标注",
                                        "descImg"    => "https://file.51kuafu.com/1d/8a/f83f3c0d4cf950478f8f7072f55a28b1d9eaa2fd2df0e1d947fde7105bd5.png",
                                        "handDrawn"  => true,
                                    ]),
            'flowLine'     => self::unit('flowLine', '人流动线', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::FLOW_LINE_TYPE_TEXT)),
            'orientation'  => self::unit('orientation', '朝向', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::ORIENTATION_TYPE_TEXT)),
            'yinYangJie'   => self::unit('yinYangJie', '阴阳街', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::YIN_YANG_JIE_TYPE_TEXT)),
            'visualLabel'  => self::unit('visualLabel', '可视性标签', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::VISUAL_LABEL_TEXT)),
            'streetLength' => self::unit('streetLength', '商业街长度', true, 'radio',
                SiteLocationEnum::getOptionsByConst(SiteLocationEnum::STREET_LENGTH_TEXT)),
        ];
    }

}
